import roslibpy

class AvailableActions:

    def __init__(self, framework):
        self.framework = framework
        self.listener = None
        self.message = None

    def subscribe(self):
        if self.framework.framework.utils.device.device_state:
            self.listener = roslibpy.Topic(self.framework.framework.utils.device.device_connect, "/alphadog_node/available_actions", "ros_alphadog/AvailableActions")
            self.listener.subscribe(self.callback)

    def callback(self, message):
        self.message = message

    def unsubscribe(self):
        if self.listener:
            self.listener.unsubscribe()
            self.listener = None
            self.message = None
